function makeBoundFunction(obj, method)
	func = function(...)
	            -- table.foreach(arg, print)
				return method(obj, unpack(arg))
			end
	return func
end


-- Compatibility: Lua-5.1
function split(str, pat)
   local t = {}  -- NOTE: use {n = 0} in Lua-5.0
   local fpat = "(.-)" .. pat
   local last_end = 1
   local s, e, cap = string.find(str, fpat, 1)
   while s do
      if s ~= 1 or cap ~= "" then
	 table.insert(t,cap)
      end
      last_end = e+1
      s, e, cap = string.find(str, fpat, last_end)
   end
   if last_end <= string.len(str) then
      cap = string.sub(str, last_end)
      table.insert(t, cap)
   end
   return t
end



function get_input(msg)
	io.write(msg)
	return io.read('*line')
end



function item_get_object(item)
    name = item.type.name.name

    print('item_get_object type name', name)

    if name == argot.uint8_name.name then return item.data.u8 end
    if name == argot.sint8_name.name then return item.data.s8 end

    if name == argot.uint16_name.name then return item.data.u16 end
    if name == argot.sint16_name.name then return item.data.s16 end

    if name == argot.uint32_name.name then return item.data.u32 end
    if name == argot.sint32_name.name then return item.data.s32 end

    if name == argot.uint64_name.name then return item.data.u64 end
    if name == argot.sint64_name.name then return item.data.s64 end


    if name == argot.u8ascii_name.name then
        string = argot.toString( item.data.ptr )
        return string
	end

    if name == argot.bool_name.name then return item.data.u8 == 1 end

    if name == argot.u32utf8_name.name then
        error('Python equivalent of U32UTF8 not yet implemented')
 	end

    if name == argot.u16binary_name.name then
        error('Python equivalent of U16Binary not yet implemented')
 	end

    if name == argot.u32binary_name.name then
        error('Python equivalent of U32Binary not yet implemented')
 	end


    print('!Unknown Type, trying lua object')
    return argot.convert_to_lua_object(item.data.ptr)

	-- TypeItem.get_object = get_object
end